# Copyright (c) 2024 IndustrialTBB Framework
# Licensed under MIT License

cmake_minimum_required(VERSION 3.16)

# 源文件列表
set(ITBB_SOURCES
    # 核心框架实现
    core/framework.cpp
    core/tbb_task_scheduler.cpp
    core/tbb_flow_pipeline.cpp
    core/tbb_concurrent_containers.cpp
    core/tbb_observer.cpp
    
    # 设备管理实现
    devices/tbb_device_interface.cpp
    devices/tbb_device_pool.cpp
    devices/tbb_device_factory.cpp
    devices/tbb_adwin_device.cpp
    
    # 配置系统实现
    config/tbb_dynamic_config.cpp
    
    # 监控系统实现
    monitoring/tbb_performance_monitor.cpp
    
    # 工具类实现
    utils/logging.cpp
    utils/json_parser.cpp
    utils/system_info.cpp
)

# 创建静态库
add_library(itbb_static STATIC ${ITBB_SOURCES})

# 创建动态库
add_library(itbb_shared SHARED ${ITBB_SOURCES})

# 设置库属性
set_target_properties(itbb_static PROPERTIES
    OUTPUT_NAME itbb
    VERSION ${PROJECT_VERSION}
    SOVERSION ${PROJECT_VERSION_MAJOR}
)

set_target_properties(itbb_shared PROPERTIES
    OUTPUT_NAME itbb
    VERSION ${PROJECT_VERSION}
    SOVERSION ${PROJECT_VERSION_MAJOR}
)

# 链接TBB
target_link_libraries(itbb_static PUBLIC TBB::tbb)
target_link_libraries(itbb_shared PUBLIC TBB::tbb)

# 包含目录
target_include_directories(itbb_static PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
    $<INSTALL_INTERFACE:include>
)

target_include_directories(itbb_shared PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
    $<INSTALL_INTERFACE:include>
)

# 编译选项
target_compile_features(itbb_static PUBLIC cxx_std_17)
target_compile_features(itbb_shared PUBLIC cxx_std_17)

# 安装规则
install(TARGETS itbb_static itbb_shared
    EXPORT itbb-targets
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin
)
